package com.ssyx.common.auth;


import com.ssyx.vo.acl.AdminLoginVo;
import com.ssyx.vo.user.UserLoginVo;

/**
 * ClassName:AuthContextHolder
 * Description:
 * ThreadLocal工具类
 * ThreadLocal叫做线程变量，意思是ThreadLocal中填充的变量属于当前线程，
 * 该变量对其他线程而言是隔离的，也就是说该变量是当前线程独有的变量。
 * ThreadLocal为变量在每个线程中都创建了一个副本，那么每个线程可以访问自己内部的副本变量。
 * @Author kay
 * @Create 2024/5/15 10:33
 * @Version 1.0
 */
public class AuthContextHolder {

    //会员用户的基本信息(UserLoginVo),前台会员
    private static ThreadLocal<UserLoginVo> userLoginVo = new ThreadLocal<>();

    //管理员基本信息(AdminLoginVo),后台管理员
    private static ThreadLocal<AdminLoginVo> adminLoginVo = new ThreadLocal<>();


    public static void setUserLoginVo(UserLoginVo _userLoginVo) {
        userLoginVo.set(_userLoginVo);
    }

    public static UserLoginVo getUserLoginVo() {
        return userLoginVo.get();
    }

    public static AdminLoginVo getAdminLoginVo() {
        return adminLoginVo.get();
    }

    public static void setAdminLoginVo(AdminLoginVo _adminLoginVo) {
        adminLoginVo.set(_adminLoginVo);
    }
}
